package com.dense.kuiniu.bookborrow.xjSetting.utils;

import android.util.Base64;

import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 密码工具器
 */
public class PasswordUtils {
    /**
     * 获取万能密码
     * @return
     */
    public static String getPassword(){//MDIxNA
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHH");
       String value= sdf.format(new Date());
       String token="";
        try {
            final byte[] textByte = value.getBytes("UTF-8");
             token= Base64.encodeToString(textByte, 0).trim();
            int length=token.length();
            if (length>8){
                token=token.substring(length-8,length-2);//token最长24
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return token.toLowerCase();
    }
}
